from django.db import models

# Create your models here.


class Article(models.Model):
    title = models.CharField(max_length=200)
    content = models.TextField(blank=True)
    category = models.ForeignKey(
        'Category', on_delete=models.SET_NULL, null=True)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    def __str__(self):
        return r"article:{title:%s}" % self.title


class Category(models.Model):
    name = models.CharField(max_length=100)

    def __str__(self):
        return r"category:{id:%s,name:%s}" % (self.pk, self.name)
